package com.gitee.feizns.dynamic.bean;

import java.util.Iterator;

/**
 * <b>属性迭代器</b>
 * <p>
 *     通过实现该接口获得遍历对象属性的功能
 * </p>
 * <pre>{@code
 *     public static void main(String[] args) {
 *         A a = new A();
 *         for (Property<Object, A> property : a) {
 *             A target = property.getTarget();
 *             System.out.println(target == a);//true
 *         }
 *     }
 *
 *     static class A implements PropertiesIterable<A> {
 *
 *     }
 * }</pre>
 * @see Iterable
 * @author feizns
 * @since 2019/6/5
 */
public interface PropertiesIterable<T extends PropertiesIterable<T>> extends Iterable<Property<Object, T>> {

    /**
     * <b>返回当前对象的属性迭代器</b>
     * @return {@link Iterator}
     */
    @SuppressWarnings("unchecked")
    @Override
    default Iterator<Property<Object, T>> iterator() {
        return PropertyUtils.props((T) this).iterator();
    }

}

